class Solution {
    List<List<Integer>> ret;
    List<Integer> path;
    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums, 0);
        return ret;
    }
    public void dfs(int[] nums, int pos) {
        //策略二
        ret.add(new ArrayList<>(path));
        //从pos位置开始向后枚举
        for(int i = pos; i < nums.length; i++) {
            //依次枚举，下标为i
            path.add(nums[i]);
            //从当前元素后面的元素中选
            dfs(nums, i + 1);
            //回溯 -> 恢复现场
            path.remove(path.size() - 1);
        }
    }
}